[2.3] build: backport NIX_ATTRS_*_FILE #12026
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
This was originally added in #4770 to support structured attrs in
nix-shell
&nix develop
: the issue was that it was somewhat awkward to just write those files into a project directory, especially since it'd break in case of multiplenix-shell
invocations from the same directory. Now the files are written to another, temporary location when usingnix-shell
/nix develop
and the correct path is referenced by NIX_ATTRS_*_FILE.In
nixpkgs
, it's now common to use these environment variables, however we still fall back to checking to.attrs.sh
&.attrs.json
since the minimum Nix version we support is 2.3.17[1] which doesn't have this change.This however makes implementing structured attrs support more complicated than needed[2] and in fact we have a few places where the check for
.attrs.sh
/.attrs.json
isn't made, so these only break with Nix 2.3[3].The idea is now to
.attrs.sh
/.attrs.json
from nixpkgs.[1] https://github.com/NixOS/nixpkgs/blob/f4bd97b8face6dc14b0ce048c20cff7e558c7be2/lib/minver.nix
[2] https://github.com/NixOS/nixpkgs/pull/357053/files#diff-791a01ef89c157eb74d9c87ab8cbc3b81e2cf082cab70b8fec3472cd75ce860dR3-R5
[3] NixOS/nixpkgs#357053 (comment)
Context
cc @wolfgangwalther @edolstra @Ericson2314
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.